import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import router from './router'

// 初始化主题
const initTheme = () => {
  const savedTheme = localStorage.getItem('themeConfig')
  if (savedTheme) {
    const theme = JSON.parse(savedTheme)
    document.documentElement.setAttribute('data-theme', theme.mode)
    document.documentElement.style.setProperty('--primary-color', theme.primaryColor)
    document.documentElement.style.setProperty('--border-radius', `${theme.borderRadius}px`)
    if (theme.colorWeakness) document.documentElement.classList.add('color-weakness')
    if (theme.compactMode) document.documentElement.classList.add('compact-mode')
  }
}

initTheme()

const app = createApp(App)

// 添加错误处理
app.config.errorHandler = (err) => {
  console.error('Vue 错误:', err)
}

// 挂载路由
app.use(router)

// 挂载应用
app.mount('#app')
